window.onload = function () {
    document.documentElement.style.fontSize = document.documentElement.clientWidth / 25 + "px";
    (function () {
        var mySwiper = new Swiper('.swiper-container', {
            direction: 'vertical',
            watchSlidesProgress: true,
            watchSlidesVisibility: true,
            slideVisibleClass: 'current',
            onSlideChangeEnd: function (swiper) {
                var index = swiper.activeIndex;
                if (index === swiper.slides.length - 1) {
                    $('.start').removeClass("rotate");
                } else {
                    $('.start').addClass("rotate");
                }
                swiperAnimate(swiper);
            },
            onInit: function (swiper) {
                swiperAnimateCache(swiper);
                swiperAnimate(swiper);
            }
        });
    })();

    (function () {
        var media = $('#media')[0];
        var audioTimer = null;

        //绑定播放暂停控制
        $('.play').on('click', function () {
            playAudio();
        });

        //播放暂停切换
        function playAudio() {
            if (media.paused) {
                play();
            } else {
                pause();
            }
        }

        //播放
        function play() {
            media.play();
            $(".audioControl > .play > img").addClass("rotate");
        }

        //暂停
        function pause() {
            media.pause();
            $(".audioControl > .play > img").removeClass("rotate");
        }
    })();

    shareevent();
    function shareevent() {
        var share_title = '王传君';
        var share_url = 'http://test.b2social.cn/hifuntvwcj/index.html';
        var share_desc = '王传君。';
        var img_url = 'http://test.b2social.cn/hifuntvwcj/images/jbhtysicon.jpg';
        $.ajax({
            type: "GET",
            url: "http://test.b2social.cn/wechatApi/initPage.do",
            data: {
                url: window.location.href
            },
            async: false,
            dataType: "json",
            success: function (data) {
                wx.config({
                    debug: false,
                    appId: data.appId, // 必填，公众号的唯一标识
                    timestamp: data.timestamp, // 必填，生成签名的时间戳
                    nonceStr: data.nonceStr, // 必填，生成签名的随机串
                    signature: data.signature,// 必填，签名，见附录1
                    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                });
                wx.ready(function () {
                    wx.checkJsApi({
                        jsApiList: [
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage'
                        ],
                        success: function (res) {

                        }
                    });
                    //朋友圈
                    wx.onMenuShareTimeline({
                        title: share_desc, // 分享标题
                        link: share_url, // 分享链接
                        imgUrl: img_url, // 分享图标
                        success: function () {
                            // 用户确认分享后执行的回调函数
                        },
                        cancel: function () {
                            // 用户取消分享后执行的回调函数
                        }
                    });
                    //分享给朋友
                    wx.onMenuShareAppMessage({
                        title: share_title, // 分享标题
                        desc: share_desc, // 分享描述
                        link: share_url, // 分享链接
                        imgUrl: img_url, // 分享图标
                        type: '',
                        dataUrl: '',
                        success: function () {
                            // 用户确认分享后执行的回调函数
                        },
                        cancel: function () {
                            // 用户取消分享后执行的回调函数
                        }
                    });
                });

                wx.error(function (res) {
                });
            }
        });
    }
};